import  {getQRcode} from  '../../../../api/shop'
Component({
  mixins: [],
  data: {
    currentSort: 1,
    showType: 'grid',
    qrCode:"",
    addressModal:false
  },
  props: {
    showTypeSwitch: true,
    goodsList: [],
    isFixed: false,
    emptyTip: '',
    isLoading: false,
    member_id:""
  },
  didMount() { 
    getQRcode(this.props.member_id).then((res)=>{
      this.setData({
       qrCode:res.data.qr_code_url_circle_blue,
     
      })
     })
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    changeType() {
       this.setData({
        addressModal:true
       })
    },
    changeSortType(e) {
      const index = e.currentTarget.dataset.index;
      this.setData({
        currentSort: index == 2 && this.data.currentSort == 2 ? 3 : index
      });
      this.props.onSortList(this.data.currentSort);
    },
    closeModal(){
      this.setData({
     addressModal:false
   })
    },
    download(){
      console.log(1221);
      const {qrCode} =this.data
      let fs = my.getFileSystemManager();
      my.downloadFile({
        url:qrCode,
        success({apFilePath}) {
          my.saveImageToPhotosAlbum({
            filePath: apFilePath,
            success: (res1) => {
              my.showToast({
                type: 'success',
                content: '下载成功',
                duration: 1000,
                success: () => {
              
                },
              });
            }
          })
        },
        fail(res) {
          console.log('downloadFile fail：',res);
        },
      });
     }
  },

});
